package my.market.display.goods;
import my.market.jdbc.dataClass.Goods;
import my.market.jdbc.dao.GoodsDao;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class GoodDetail
 */
@WebServlet("/getgooddetail")
public class GetGoodDetail extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private static Goods good = null;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GetGoodDetail() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String id = request.getParameter("id");
		GoodsDao gDao = new GoodsDao();
		try {
			good = gDao.findGoodById(id);
		} catch (SQLException e) {
			e.printStackTrace();
			// TODO: handle exception
		}
		request.setAttribute("find_good", good);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
